package com.cskaoyan.utils;

import com.cskaoyan.bean.MarketUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;

/**
 * @author erdonc
 * @date 2022/9/9 19:36
 * @description: TODO
 */
public class GetUserInfoUtils {
    public static MarketUser getUserInfo() {
        Subject subject = SecurityUtils.getSubject();
        PrincipalCollection principals = subject.getPrincipals();
        if (principals == null) {
            subject.logout();
        }
        MarketUser principal = (MarketUser) principals.getPrimaryPrincipal();
        return principal;
    }
}
